﻿using System;
using System.Linq;
using DirectoryServicesProtocolsExtensions.SearchRequest;

namespace IntegrationTests
{
    class MockEdirectoryQueryPropertiesContainer : ILdapSearchRequestPropertiesContainer
    {
        private string searchBaseDN = "O=IT";
        private string searchFilter = "(objectClass=*)";
        private string[] attributesToLoad = new[] { "entryDN", "givenName", "sn", "cn" };
        private int pageSize = 1000;
        private string uniqueObjectIdentifierAttribute = "entryDN";
        private bool includeObjectOwnerInfo = false;
        private bool enforceDomainScope = false;

        public string SearchBaseDN
        {
            get
            {
                return searchBaseDN;
            }

            set
            {
                searchBaseDN = value;
            }
        }

        public string SearchFilter
        {
            get
            {
                return searchFilter;
            }

            set
            {
                searchFilter = value;
            }
        }

        public int PageSize
        {
            get
            {
                return pageSize;
            }

            set
            {
                pageSize = value;
            }
        }

        public string UniqueObjectIdentifierAttribute
        {
            get { return uniqueObjectIdentifierAttribute; }
            set { uniqueObjectIdentifierAttribute = value; }
        }

        public bool IncludeObjectOwnerInfo
        {
            get { return includeObjectOwnerInfo; }
            set { includeObjectOwnerInfo = value; }
        }

        public bool IsDomainScopeEnforced
        {
            get { return enforceDomainScope; }
            set { enforceDomainScope= value; }
        }

        public string[] AttributesToLoad
        {
            get
            {
                if (!attributesToLoad.Contains(UniqueObjectIdentifierAttribute, StringComparer.OrdinalIgnoreCase))
                {
                    Array.Resize(ref attributesToLoad, attributesToLoad.Length + 1);
                    attributesToLoad[attributesToLoad.Length - 1] = UniqueObjectIdentifierAttribute;
                }

                return attributesToLoad;
            }

            set
            {
                attributesToLoad = value;
            }
        }
    }
}
